<template>
	<view class="container">
		<view class="center-container">
			<view class="item">
				订单ID: {{order.id}}
			</view>
			<view class="item">
				收货地址: {{order.receiveAddress}}
			</view>
			<view class="item">
				创建时间: {{order.createDate}}
			</view>
			<view class="item">
				支付金额: ￥ {{order.amount}}
			</view>
			<view class="item">
				<view v-if="order.isPay === '支付成功' " style="height: 90rpx; margin-top: 20rpx;">
					<text style="color: red; "> 已支付</text>
				</view>
				<view v-else-if="order.isPay === '支付失败' " style="height: 90rpx; margin-top: 20rpx;">
					<text style="color: #c8a44f; "> 支付失败</text>
				</view>
				<view class="box-bottom" v-else>
					<text style="color: #c87777">未支付</text>
					<view class="btn">
						<button type="primary" class="btn-1" @click="payOrder">去支付</button>
					</view>

				</view>
			</view>

		</view>

	</view>
</template>

<script>
	export default {
		name: "my-order",
		props: {
			order: {
				type: Object,
				defaultValue: {
					id: 0,
				}
			},
		},
		data() {
			return {

			};
		},
		created() {

		},
		mounted() {

		},
		methods: {
			async payOrder() {
				const orderId = uni.getStorageSync("orderId")
				if (orderId == "") return
				const res = await uni.$dapi.getCheck(orderId)
				console.log("my-order", res);

				uni.navigateTo({
					url: '../../subpkg/order_detail/order_detail'
				})
			},
			refresh() {
				this.$forceUpdate()
			}

		}

	}
</script>

<style lang="scss" scoped>
	.container {
		z-index: 2;
		clear: both;
		display: flex;
		height: 100%;
		width: 100%;
		text-align: center;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		border-radius: 40rpx;

		box-shadow: #bfccb7;

		padding: 20rpx 0rpx;


		// background-color: #ccc;

		&:hover {
			background-color: #bfccb7;
		}

		.center-container {
			display: flex;
			flex-direction: column;
			align-items: center;
			width: 80%;
			background-color: #7dc2c8;
			border-radius: 20rpx;

			.item {
				width: 80%;

				.box-bottom {
					display: flex;
					flex-direction: row;
					justify-content: space-evenly;
					align-items: center;


					.btn {
						// display: flex;
						// flex-direction: column;
						// justify-content: center;
						// align-items: center;
						text-align: center;

						.btn-1 {
							border-radius: 80px;
							margin: 15px auto;
							background-color: #C00000;
						}
					}
				}
			}
		}


	}
</style>